<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改学院</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">学院ID</label>
                    <div class="layui-input-block">
                        <input id="collegeId" type="text" name="collegeId" value="" lay-verify="required"
                               autocomplete="off"
                               placeholder="请输入学院ID" class="layui-input"
                               lay-reqText="请输入学院ID">
                        <span class="layui-badge"
                              id="userIdTips" style="text-align: center;display: none">该学院已存在
                        </span>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">学院名称</label>
                    <div class="layui-input-block">
                        <input id="collegeName" type="text" name="collegeName" lay-verify="required" autocomplete="off"
                               placeholder="请输入学院名称"
                               class="layui-input" lay-reqText="请输入学院名称">
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">学院概述</label>
                    <div class="layui-input-block">
                        <textarea id="collegeIntroduce" name="collegeIntroduce" required lay-verify="title" placeholder="请输入学院概述"
                                  class="layui-textarea" style="height: 210px"></textarea>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery','laydate'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;


        laydate.render({
            elem: '#birthday' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,theme: 'molv'
            ,calendar: true
        });

        form.on('submit(user-save)', function (data) {
            let index = layer.load(2, {time: 10*1000}); //又换了种风格，并且设定最长等待10秒
            $.ajax({
                url: '/College/updateCollege',
                data: data.field,
                dataType: 'json',
                type: 'get',
                success: function (result) {
                    layer.close(index);
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            //console.log(parent.layui.jquery(".layui-laypage-em").next().html());
                            parent.layui.table.reload("user-table", {
                                data: result.data,
                                page: {
                                    layout: ['count', 'prev', 'page', 'next', 'skip']
                                    , curr: parent.layui.jquery(".layui-laypage-em").next().html()
                                    , groups: 3
                                    , last: false
                                }
                            });
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>
